

import 'package:bike_ride/model/cycle_record/view/cycle_record_v.dart';
import 'package:bike_ride/model/cyling/view/cyling_v.dart';
import 'package:bike_ride/model/entrance/view/entrance_v.dart';
import 'package:bike_ride/model/fault_report/view/fault_report_v.dart';
import 'package:bike_ride/model/freight/view/freight_v.dart';
import 'package:bike_ride/model/pay/view/pay_box_v.dart';
import 'package:bike_ride/model/wallet/model/recharge_arrow_m.dart';
import 'package:bike_ride/model/wallet/view/lately_recharge_info.dart';
import 'package:bike_ride/model/wallet/view/lately_recharge_v.dart';
import 'package:bike_ride/model/login/view/login_v.dart';
import 'package:bike_ride/model/main/model/user_info_m.dart';
import 'package:bike_ride/model/main/view/main_v.dart';
import 'package:bike_ride/model/mine/view/mine_v.dart';
import 'package:bike_ride/model/order_detail/view/order_detail_v.dart';
import 'package:bike_ride/model/pay/view/pay_v.dart';
import 'package:bike_ride/model/personal/view/personal_v.dart';
import 'package:bike_ride/model/protocol/view/protocol_v.dart';
import 'package:bike_ride/model/question/view/question_v.dart';
import 'package:bike_ride/model/scan/view/scan_v.dart';
import 'package:bike_ride/model/unlock/view/unlock_v.dart';
import 'package:bike_ride/model/wallet/view/transactions_page.dart';
import 'package:bike_ride/model/wallet/view/wallet_v.dart';
import 'package:bike_ride/model/web/view/webview_page.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';

class Routers{
  static FluroRouter router = FluroRouter();
  // 页面标识
  static String entranceView = '/EntranceView';

  // 登录页面
  static String loginView = '/LoginView';

  // 首页
  static String appMainPage = '/AppMainPage';
  // 个人中心
  static String mineView = '/MineView';
  static String questionView = '/QuestionView';
  // webView
  static String webViewPage = '/WebViewPage';
  static String htmlContent = '/HtmlContent';
  // 设置中心、个人资料
  static String personalView = '/PersonalView';
  static String protocolView = '/ProtocolView';
  // 扫码
  static String qrcodeScanPage = '/QrcodeScanPage';
  static String enterCodePage = '/EnterCodePage';
  static String unLockView = '/UnLockView';
  static String cyclingView = '/CyclingView';
  static String payView = '/PayView';
  static String payBoxView = '/PayBoxView';
  static String cyclingRecordView = '/CyclingRecordView';
  static String orderDetailView = '/OrderDetailView';
  static String walletView = '/WalletView';
  static String latelyRechargeView = '/LatelyRechargeView';
  static String latelyRechargeInfoPage = '/LatelyRechargeInfoPage';
  static String transactionsPage = '/TransactionsPage';
  static String faultReportView = '/FaultReportView';
  static String freightView = '/FreightView';


  // 配置路由
  static void configureRouters() {
    router.notFoundHandler = Handler(handlerFunc: (_, __) {
      // 找不到路由时，返回指定提示页面
      return const Scaffold(
        body: Center(
          child: Text('404'),
        ),
      );
    });

    // 初始化路由
    _initRouter();
  }

  static _initRouter() {
    // 根页面
    router.define(
      entranceView,
      handler: Handler(
        handlerFunc: (_, __) => const EntranceView(),
      ),
    );

    // 登录页面
    router.define(
      loginView,
      handler: Handler(
        handlerFunc: (_, __) => const LoginView(),
      ),
    );

    // 首页
    router.define(
      appMainPage,
      handler: Handler(
        handlerFunc: (_, __) => const AppMainPage(),
      ),
    );

    router.define(
      mineView,
      handler: Handler(
        handlerFunc: (_, __) => const MineView(),
      ),
    );

    router.define(
      questionView,
      handler: Handler(
        handlerFunc: (_, __) => const QuestionView(),
      ),
    );

    router.define(
      webViewPage,
      handler: Handler(
        handlerFunc: (context, __) => WebViewPage(arguments: context?.settings?.arguments as Map<String, dynamic>,),
      ),
    );
    router.define(
      htmlContent,
      handler: Handler(
        handlerFunc: (context, __) => HtmlContent(arguments: context?.settings?.arguments as Map<String, dynamic>,),
      ),
    );

    router.define(
      personalView,
      handler: Handler(
        handlerFunc: (context, __) {
          UserInfoM? paramsModel = context?.settings?.arguments as UserInfoM?;
          return PersonalView(model:paramsModel);
        },
      ),
    );

    router.define(
      protocolView,
      handler: Handler(
        handlerFunc: (_, __) => const ProtocolView(),
      ),
    );
    router.define(
      qrcodeScanPage,
      handler: Handler(
        handlerFunc: (_, __) => const QrcodeScanPage(),
      ),
    );

    router.define(
      enterCodePage,
      handler: Handler(
        handlerFunc: (_, __) => const EnterCodePage(),
      ),
    );


    router.define(
      unLockView,
      handler: Handler(
        handlerFunc: (context, __) {
          final vid = context?.settings?.arguments as String;
          return UnLockView(vid:vid);
        }
      ),
    );

    router.define(
      cyclingView,
      handler: Handler(
        handlerFunc: (context, __) =>CyclingView(arguments:context?.settings?.arguments as Map<String, dynamic>,)
      ),
    );

    router.define(
      payView,
      handler: Handler(
        handlerFunc: (context, __) =>PayView(arguments:context?.settings?.arguments as Map<String, dynamic>,)
      ),
    );

    router.define(
      payBoxView,
      handler: Handler(
        handlerFunc: (context, __) =>PayBoxView(arguments:context?.settings?.arguments as Map<String, dynamic>,)
      ),
    );

    router.define(
      cyclingRecordView,
      handler: Handler(
        handlerFunc: (_, __) => const CyclingRecordView(),
      ),
    );

    router.define(
      walletView,
      handler: Handler(
          handlerFunc: (context, __) =>WalletView(arguments:context?.settings?.arguments as Map<String, dynamic>?,)
      ),
    );

    router.define(
      latelyRechargeView,
      handler: Handler(
        handlerFunc: (_, __) => const LatelyRechargeView(),
      ),
    );

    router.define(
      transactionsPage,
      handler: Handler(
        handlerFunc: (_, __) => const TransactionsPage(),
      ),
    );

    router.define(
      latelyRechargeInfoPage,
      handler: Handler(
        handlerFunc: (context, __) {
          RechargeArrowM paramsModel = context?.settings?.arguments as RechargeArrowM;
          return LatelyRechargeInfoPage(model:paramsModel);
        },
      ),
    );

    router.define(
      orderDetailView,
      handler: Handler(
          handlerFunc: (context, __) =>OrderDetailView(arguments:context?.settings?.arguments as Map<String, dynamic>,)
      ),
    );

    router.define(
      faultReportView,
      handler: Handler(
          handlerFunc: (context, __) =>FaultReportView(arguments:context?.settings?.arguments as Map<String, dynamic>?,)
      ),
    );

    router.define(
      freightView,
      handler: Handler(
          handlerFunc: (context, __) =>FreightView(arguments:context?.settings?.arguments as Map<String, dynamic>?,)
      ),
    );

  }

}